<#assign ctx=request.contextPath />
<#macro table name show url title="name" id="id">
<div id="search_area_${name}">
	<input type="text" placeholder="查询" autocomplete="off" name="${show}"
	class="layui-input" readonly="readonly">
	<input name="${name}" type="hidden" />
</div>
	<script type="text/javascript">
        	layui.use(['layer'],function(){
        		var layer = layui.layer;
        		var $ = layui.$;

        		$("input[name='${show}']").unbind('click');
        		$("input[name='${show}']").bind('click',function(){
        			var $holder = $(this);
    				var index = layer.open({
   					 type:2,
   					 title:'请选择',
   					 maxmin :true,
   					 content:['${url}'],
   					 area:['70%','70%'],
   					 success:function(layero,index){
   						 var iframeWin = window[layero.find('iframe')[0]['name']];
   						 $(iframeWin.document).find("#parent_name").val("${name}");

   						$(iframeWin.document).find("#check_btn").bind('click',function(){
   							var checkStatus = iframeWin.layui.table.checkStatus('search_table');
   							var index = layer.getFrameIndex(iframeWin.name); //获取窗口索引
   							if(checkStatus.data.length == 1) {
   								var data = checkStatus.data[0];
   								var show = [];
   								for(var v in data) {
   									show.push(data[v])
   								}
   								$holder.val(data['${title}']);
   								$holder.next().val(data['${id}']);
   								$(top).trigger('select_done','${name}',data);
   							}
   						    layer.close(index);
   						});
   					 }
   				});
           		layer.iframeAuto(index)
        		});
        	});
	</script>
</#macro>